Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
How to capture "close browser windows" and then update a DataBase item with Django?

Context:

I have a web application in Django. This application is a dashboard where the users can verify and validate the recognition made by an AI of each part of an invoice (prices, taxes...).

The user can manually review this recognition and consequently validate if everything is correct.

Situation:

When a user clicks on the verify button, it will redirect the user to another view. This new view is a Django template with an iframe. This Django view executes a function which updates the status of the item to '31.Verificando usuario' in the DB.

urls.py:

path('verification/<int:id>/', views.VerificationPage, name="fci-verification" )

views.py:

def VerificationPage (request, id):
    invoice= Invoice.objects.get(id=id)
    url= invoice.verification_url
    invoice_id = invoice.id
    status = '31.Verificando usuario'
    message = _('Invoice in web verification')
    try:
        change_invoice_status(invoice_id, status, message)
    except Exception as e:
        capture_exception(e)
    return render(request, "fci_verification.html", {'verification_url': 
                  url,'invoice_id': id})

When this user clicks on "verified" into iframe, I catch this event with window.addEventListener("message", receiveMessage, false); and update to new status.

Problem:

If the user closes the tab or browser, the item status stays as "31.Verificando usuario" and another user cannot review this invoice.

How can I capture a "close windows or tab" event and change the status to the previous status?

RESUME:

  1. I have a dashboard to verify invoices.
  2. When the user clicks on the verify button, the invoice status is updated to "31.Verificando usuario" .
  3. If user close browser without verify the invoice, this invoice stays with wrong status.
  4. I need capture this "close tab/browser" and update to the previous status.
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda